package com.wonders.ghy.算法.冒泡;

/**
 * 冒泡排序 时间复杂度 O(n^2)
 *
 */
public class One {
    public static void main(String[] args) {
        int[] array = {1, 8, 3,56,4,21,1};
        int length = array.length;
        for (int i = 0; i < length - 1; i++) {
            for (int j = 0; j < length - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < length; i++) {
            System.out.print(array[i] + " ");
        }
    }
}
